/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.mzk.kramerius.articles.importFromLn.cli;

import cz.mzk.kramerius.articles.importFromLn.AuthorStatistics;
import cz.mzk.kramerius.articles.importFromLn.articlesData.ArticleDataParser;
import cz.mzk.kramerius.articles.importFromLn.domain.Article;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Prints information about process of resolving author names and also values and number of
 * appearances of those strings that could not be resolved.
 *
 * @author Martin Řehánek (rehan@mzk.cz)
 */
class AnalyzeAuthorsAction implements Action {

    private static final Logger logger = Logger.getLogger(AnalyzeAuthorsAction.class.getName());
    private final ArticleDataParser parser;

    public AnalyzeAuthorsAction(ArticleDataParser parser) {
        this.parser = parser;
    }

    @Override
    public void run() {
        parser.parseArticles();
        List<Article> articles = parser.getCorrectArticles();
        if (articles != null) {
            AuthorStatistics stats = new AuthorStatistics(articles);
            stats.printStatistics(System.out, true);
        } else {
            logger.log(Level.SEVERE, "articles == null");
        }
    }
}
